package people;

import static org.junit.Assert.*;

import org.junit.Test;

public class A1X01_AddressExtraTest {

	// For experts only. For details see:
	// http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html#hashCode()
	@Test
	public void expertsKnowThatEqualObjectsHaveTheSameHashcode()
			throws Exception {

		Address address1 = new Address("Am Wichelshof 32", "53111", "Bonn");
		Address address2 = new Address("Am Jesuitenhof 1 + 3", "53117", "Bonn");
		Address address3 = new Address("Am Jesuitenhof 1 + 3", "53117", "Bonn");

		assertFalse(address1.hashCode() == address2.hashCode()); // Could be true by chance.
		assertTrue(address2.hashCode() == address3.hashCode());
	}
	/*
	 * Can you write some extra code to show that the changes you made to make
	 * the test succeed are necessary to use the Address class in a HashSet or a
	 * HashMap?
	 */

}
